<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="修改收款信息" bodyClass="white-bg" libs=["prism","bootstrapSelect","ueditor"]/>
<div class="wrapper wrapper-content ibox-content">
    <@form.form id="form-collectionmoney-edit"  class="form-horizontal">
    <input name="id" value="${bpmCrmCollectionmoney.id}" type="hidden">
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "销售员" />：                               <i class="fa fa-question-circle-o" title="销售员"></i>                                
       </label>
        <div class="col-sm-8"><input name="saleUserid" value="${bpmCrmCollectionmoney.saleUserid?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "销售订单编号" />：                               <i class="fa fa-question-circle-o" title="销售订单编号"></i>                                
       </label>
        <div class="col-sm-8"><input name="saleOrderNumber" value="${bpmCrmCollectionmoney.saleOrderNumber?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "车辆识别号" />：                               <i class="fa fa-question-circle-o" title="车辆识别号"></i>                                
       </label>
        <div class="col-sm-8"><input name="outCarVin" value="${bpmCrmCollectionmoney.outCarVin?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "车型" />：                               <i class="fa fa-question-circle-o" title="车型"></i>                                
       </label>
        <div class="col-sm-8"><input name="outCarVehicle" value="${bpmCrmCollectionmoney.outCarVehicle?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "付款方式"/>：</label>
        <div class="col-sm-8">          
             <@form.select name="paymentMethod" dictType="sys_crm_coll_paymethod" value="${bpmCrmCollectionmoney.paymentMethod?default('')}"   required="true"  />
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "交易日期"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="transactionDate"  data-type="date"   value="${(bpmCrmCollectionmoney.transactionDate?string('yyyy-MM-dd'))!}" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "输入金额" />：                               <i class="fa fa-question-circle-o" title="输入金额"></i>                                
       </label>
        <div class="col-sm-8"><input name="enterAmount" value="${bpmCrmCollectionmoney.enterAmount?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "付款人姓名" />：                               <i class="fa fa-question-circle-o" title="付款人姓名"></i>                                
       </label>
        <div class="col-sm-8"><input name="payerName" value="${bpmCrmCollectionmoney.payerName?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "证明/收据" />：                               <i class="fa fa-question-circle-o" title="证明/收据"></i>                                
       </label>
        <div class="col-sm-8"><input name="payerProofFilepath" value="${bpmCrmCollectionmoney.payerProofFilepath?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="payerMemo" class="form-control" required>${bpmCrmCollectionmoney.payerMemo?default("")}</textarea>
        </div>
    </div>
               
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收到金额" />：                               <i class="fa fa-question-circle-o" title="收到金额   （校验：enter amount差值少于5%）"></i>                                
       </label>
        <div class="col-sm-8"><input name="amountReceived" value="${bpmCrmCollectionmoney.amountReceived?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="cashierMemo" class="form-control" required>${bpmCrmCollectionmoney.cashierMemo?default("")}</textarea>
        </div>
    </div>
               
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳证明" />：                               <i class="fa fa-question-circle-o" title="出纳证明"></i>                                
       </label>
        <div class="col-sm-8"><input name="cashierProofFilepath" value="${bpmCrmCollectionmoney.cashierProofFilepath?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收据编号" />：                               <i class="fa fa-question-circle-o" title="收据编号（需要校验是否重复）"></i>                                
       </label>
        <div class="col-sm-8"><input name="checkmoneyReceiptnumber" value="${bpmCrmCollectionmoney.checkmoneyReceiptnumber?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "接收日期"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="receivedDate"  data-type="date"   value="${(bpmCrmCollectionmoney.receivedDate?string('yyyy-MM-dd'))!}" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳审核"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="cashierReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmCollectionmoney.cashierReview?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "订单生效日"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="orderTakeEffectTime"  data-type="date"   value="${(bpmCrmCollectionmoney.orderTakeEffectTime?string('yyyy-MM-dd'))!}" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收款日"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="collectionTime"  data-type="date"   value="${(bpmCrmCollectionmoney.collectionTime?string('yyyy-MM-dd'))!}" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "利息率" />：                               <i class="fa fa-question-circle-o" title="利息率（默认千分之八）"></i>                                
       </label>
        <div class="col-sm-8"><input name="interestRate" value="${bpmCrmCollectionmoney.interestRate?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "财务经理审核"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="financeManagerReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmCollectionmoney.financeManagerReview?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "经理复核" />：                               <i class="fa fa-question-circle-o" title="经理复核"></i>                                
       </label>
        <div class="col-sm-8"><input name="managerReview" value="${bpmCrmCollectionmoney.managerReview?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
</@form.form>
<@footer>
<script type="text/javascript">
    var prefix = baseURL + "bpm/collectionmoney";
    $("#form-collectionmoney-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        var newString=$('#form-collectionmoney-edit').serialize();
        var intervalDay='';
        var orderTakeEffectTime=$("[name='orderTakeEffectTime']").val();
        var collectionTime=$("[name='collectionTime']").val();
        if(!isNullOrEmpty(orderTakeEffectTime)&&!isNullOrEmpty(collectionTime)){
            var timeSpan=new Date(collectionTime)-new Date(orderTakeEffectTime);
            intervalDay=Math.floor(timeSpan/(24*3600*1000)).toString();
        }
        var interestRate=$("[name='interestRate']").val();
        var amountReceived=$("[name='amountReceived']").val();
        var costOfCapital=parseFloat(amountReceived)*parseInt(intervalDay)*parseFloat(interestRate);
        if(newString.includes("intervalDay")){
            newString=newString.replace("&intervalDay=",("&intervalDay="+intervalDay));
        }
        else{
            newString=newString+ "&intervalDay="+intervalDay;
        }
        if(newString.includes("costOfCapital")){
            newString=newString.replace("&costOfCapital=",("&costOfCapital="+costOfCapital.toFixed(4)));
        }
        else{
            newString=newString+ "&costOfCapital="+costOfCapital.toFixed(4);
        }
        if (opt.validate.form()) {
            opt.operate.save(prefix + "/edit", newString);
        }
    }
    function isNullOrEmpty(value) {
        return value==''||value==null||value==undefined;
    }
</script>
</@footer>
</@pageTheme>
